//
//  FirstCollectionCell.m
//  Protect -A
//
//  Created by 付剑英 on 16/6/18.
//  Copyright © 2016年 付剑英. All rights reserved.
//

#import "FirstCollectionCell.h"
#import <Masonry.h>
#import "baseLabel.h"
#import "baseImageView.h"
#import <UIImageView+WebCache.h>
@interface FirstCollectionCell ()
//@property (nonatomic,retain) baseLabel *labelofname;//图片下的名字
//@property (nonatomic,retain) baseImageView *imagevview;//图片
@end


@implementation FirstCollectionCell

#pragma mark - ------------ 初始化 ---------------

- (instancetype)initWithFrame:(CGRect)frame{
    
    self = [super initWithFrame:frame];
    if (self) {
        [self create];
    }
    return self;
    
}
#pragma mark - ------------ 创建 ---------------

-(void)create{
    
    self.labelofname = [[baseLabel alloc]init];
    [self.contentView addSubview:self.labelofname];
    
    self.imagevview = [[baseImageView alloc]init];
    [self.contentView addSubview:self.imagevview];
    
    
    [_imagevview release];
    [_labelofname release];
    
//    self.imagevview.backgroundColor = [UIColor redColor];
//    self.labelofname.backgroundColor = [UIColor blueColor];

}
#pragma mark - ------------ 布局 ---------------

-(void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes{
    
    [self.imagevview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.mas_equalTo(self.contentView).offset(20);
        make.width.height.mas_equalTo(50);
    }];
     [self.labelofname mas_makeConstraints:^(MASConstraintMaker *make) {
         make.top.mas_equalTo(self.imagevview);
         make.left.mas_equalTo(_imagevview.mas_right).offset(10);
         make.right.mas_equalTo(self.contentView).offset(-5);
         make.height.mas_equalTo(_imagevview);

     }];

    
}

#pragma mark - ------------ 重写model的set方法 ---------------

-(void)setModel:(ModelOfFirstDetail *)model{
    if (_model != model) {
        [_model release];
        _model = [model retain];
    }
    
    _labelofname.text =model.name;
    [_imagevview sd_setImageWithURL:[NSURL URLWithString:model.icon_url]];
    
}




@end
